%% the modified dynamic constraint handling technique

% val = objective function value. 
% Di = inequality function value.  
% Dj = equality function value.  
% Dj = equality function value.  
% iga = generation number.
% con, alpha, beta1, beta2 = penalty factors.   
% eps = error tolerance. 
% A = number of inequality functions. 
% B = number of equality functions.  

% developed by Omar Arif Abdul-Rahman 
% 2012

function f = const_handl5( val, Di, Dj,iga, con, alpha, beta1, beta2, eps, A, B)

[IX,n] = size(val);
Di(Di <= eps) = 0;
Di = abs(Di);
if A == 1
    Di = Di';
else
   Di = sum(Di)';
end;

if beta1 > 1
   for m = 1: IX 
       if Di(m,1) > 1
           Di(m,1) = Di(m,1)^beta1;
       end;
   end;
end;
    
Dj = abs(Dj);
Dj(Dj <= eps) = 0;
if B == 1
    Dj = Dj';
else
   Dj = sum(Dj)';
end;

if beta2 > 1
   for m = 1: IX 
       if Dj(m,1) > 1
           Dj(m,1) = Dj(m,1)^beta2;
       end;
   end;
end;


SVC =  Di + Dj;
f = val + (con*iga)^alpha*SVC;
end

